package day20180129.designMode.six_Prototype;

import java.util.HashMap;

/**
 * Created by 14394 on 2018/1/29.
 */
//使用Product接口复制实例的类
public class Manager {
    private HashMap showcace = new HashMap();//存放Project接口

    public  void register(String name,Product proto){//注册product接口，放入map
        showcace.put(name,proto);
    }

    public Product create(String protoname){//通过product子类实例名称，获取product接口，java多态性自动调用子类的clone复制方法
        Product p = (Product) showcace.get(protoname);
        return p.createClone();
    }


}
